use crate::gen_title;

pub fn ch2_5_1() {
    gen_title("ch2_5_1", 18);

    another_function(5, 6.1);
}

fn another_function(x: i32, y: f32) {
    println!("The value of x is: {}", x);
    println!("The value of y is: {}", y);
}

pub fn ch2_5_2() {
    gen_title("ch2_5_2", 18);

    let x = plus_five(5);
    println!("The value of x is: {}", x);
}

fn plus_five(x: i32) -> i32 {
    x + 5
}

pub fn ch2_5_3() {
    gen_title("ch2_5_3", 18);

    let x = plus_or_minus(5);

    println!("The value of x is: {}", x);
}

fn plus_or_minus(x: i32) -> i32 {
    if x > 5 {
        return x - 5;
    }

    x + 5
}

pub fn ch2_5_pra_1() {
    gen_title("ch2_5_pra_1", 18);

    let (x, y) = (1, 2);
    let s = sum(x, y);

    assert_eq!(s, 3);
    println!("x = {}, y = {}, s = {}", x, y, s);
}

fn sum(x: i32, y: i32) -> i32 {
    x + y
}

pub fn ch2_5_pra_2() {
    gen_title("ch2_5_pra_2", 18);

    print();
}

fn print() -> () {
    println!("hello,world");
}
